package library;

import library.Book;

//提供这个类来管理书籍对象
public class BookList {
    //最多容纳一百本数，提前设点空间
    private Book[] books  = new Book[100];
    //当前数组中有效元素个数
    private int size=0;

    //为BookList提供构造方法
    public BookList() {
        books[0] = new  Book ("西游记","吴承恩",39.8,"经典",false);
        books[1] = new Book("三国演义","罗贯中",39.9,"经典",false);
        books[2]= new Book ("红楼梦","曹雪芹",108.0,"经典",false);
        books[3] =new Book("java入门到精通","詹姆斯高斯林",70,"计算机",false);
        size=4;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }
//此处发现，针对数组属性生成的get和set方法，是针对整个数组来进行的
    //但我们希望看到的是针对某个数组的元素的get和set


    public Book getBook(int index){
        return books[index];
    }
    public void setBook(int index,Book book){
        books[index]=book;
    }

}
